﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.IO;

namespace Mokey.Common.Forms
{
    public static class ValidationHelper
    {
        public static bool ValidateFileExists(TextBox fileTextBox, Control textBoxLabel)
        {
            try
            {
                if (File.Exists(fileTextBox.Text.Trim()))
                {
                    textBoxLabel.ForeColor = Color.Black;
                    return true;
                }
                else
                {
                    UIHelper.DisplayValidationMessage(string.Format("Could not find {0} file: {1}", textBoxLabel.Text, fileTextBox.Text));
                }
            }
            catch (Exception)
            {
                UIHelper.DisplayValidationMessage(string.Format("Error processing {0} file: {1}", textBoxLabel.Text, fileTextBox.Text));
            }

            textBoxLabel.ForeColor = Color.Red;
            return false;
        }
    }
}
